package course.java.hr;

import java.util.*;

public class Company extends TaxableEntity
{
	private Collection<TaxableEntity> employees;

	public Company(String name, String taxId)
	{
		super(name, taxId);

		employees = new LinkedList<>(); // new TreeSet<>(new Comparator<TaxableEntity>() {
//			@Override
//			public int compare(TaxableEntity arg0, TaxableEntity arg1)
//			{
//				return compareEmployeesByTaxId(arg0, arg1);
//			}
//		});
	}

	private int compareEmployeesByTaxId(TaxableEntity arg0, TaxableEntity arg1)
	{
		return arg0.getTaxId().compareTo(arg1.getTaxId());
	}

	public void hire(TaxableEntity newhire, TaxableEntity... newHires)
	{
		employees.add(newhire);
		for (TaxableEntity newHire : newHires)
			employees.add(newHire);
	}


	public float pay()
	{
		float total=0;
		for (TaxableEntity te : employees)
		{
			total += te.pay();
		}
		return total;
	}

	@Override
	protected String getTaxIdRegex()
	{
		return "^\\d\\d-\\d{7}";
	}

	public Collection<TaxableEntity> getEntities()
	{
		return Collections.unmodifiableCollection(employees);
	}

}
